/*!
\file Chariot.h
\author Po
\brief The chariot object class.
*/
#pragma once

#include <d3d9.h>
#include <d3dx9.h>
#include "Interface.h"

class Platform;
class Gun;

/*!
class Chariot
\brief chariot can move on a Platform.
*/
class Chariot : public Target
{
public:
	/*! Construct a chariot using IDirect3DDevice9. Chariot is <b>NOT</b> own this device.*/
	Chariot(IDirect3DDevice9 *pd3dDevice);
	/*! Destruct the chariot. */
	~Chariot(void);

public:
	/*! Should set platform before Chariot::Update() called. */
	void SetPlatform(Platform *pPlatform);
	/*! Set the chariot move speed, if not, use default speed 20.0f. */
	void SetSpeed(float speed);

public:
	/*! Return chariot position. */
	const D3DXVECTOR3 &Position() const;
	/*! Return chariot look vector (the direction of chariot). */
	const D3DXVECTOR3 &Look() const;
	/*! Return the world matrix of chariot. */
	const D3DXMATRIX &World() const;

public:
	/*! Rotate chariot fAngle radian. */
	void UpdateRotationY(float fAngle);
	/*! Should call this function one frame a time. */
	void Update();

private:
	Chariot(const Chariot &);
	Chariot &operator=(const Chariot &);

private:
	LPDIRECT3DDEVICE9 m_pd3dDevice;
	LPD3DXMESH m_pCylinder;
	D3DXMATRIX m_matWorld;
	D3DXMATRIX m_matMove;
	D3DXVECTOR3 m_vecPosition;
	D3DXVECTOR3 m_vecLook;

	Platform *m_pPlatform;
	Gun *m_pGun;
	float m_fSpeed;
	float m_fMoveX;
	float m_fMoveZ;
	float m_fRotationAngleY;
	float m_fShootDelaySecond;
	DWORD m_dwLastShootStamp;
};

